﻿@model GraduationProject.Webs.Models.NovelModel
@using GraduationProject.Model
@{
    Layout = null;
    var UserModel = ViewData["UserModel"] as User;
    var SortModel = ViewData["SortModel"] as List<SortList>;
}

<!DOCTYPE html>
<!-- saved from url=(0032)http://javagood.cn/jie/detail/20 -->
<html style="">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>孤独的旅行家</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/css/global2.css" rel="stylesheet" />
    <script src="~/Content/js/hm.js"></script>
</head>
<body>
    <!-- 头部 -->
    <div class="fly-header layui-bg-blue">
        <div class="layui-container">
            <a class="fly-logo" href="/Home/Index">
                <img src="~/Content/layui/images/logo.png" alt="layui">
            </a>
            <ul class="layui-nav fly-nav layui-hide-xs">
                <li class="layui-nav-item">
                    <a href="/Home/MapPage"><i class="iconfont icon-jifen"></i>地图</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/Admin/AdminLogin/AdminLogin"><i class="iconfont icon-iconmingxinganli"></i>后台</a>
                </li>
                <span class="layui-nav-bar"></span>
            </ul>
            @if (UserModel != null)
            {
                <ul class="layui-nav fly-nav-user">
                    <li class="layui-nav-item">
                        <a class="fly-nav-avatar" href=""><img src="@UserModel.HeadPortrait" class="layui-nav-img">@UserModel.UserName</a>
                        <dl class="layui-nav-child">
                            <dd><a href="/Novel/InsertNovel">发表文章</a></dd>
                            <dd><a href="/UserInfo/UpDatePW">修改密码</a></dd>
         
                            <dd><a href="/UserInfo/LoginPage">退出</a></dd>
                        </dl>
                    </li>
                </ul>
            }
            else
            {
                <ul class="layui-nav fly-nav-user">
                    <!-- 未登入的状态 -->
                    <li class="layui-nav-item">
                        <a class="iconfont icon-touxiang layui-hide-xs" href="/UserInfo/LoginPage"></a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="/UserInfo/LoginPage">登入</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="/UserInfo/RegistrationPage">注册</a>
                    </li>
                    <span class="layui-nav-bar"></span>
                </ul>
            }
        </div>
    </div><!-- 头部 end -->
    <div class="layui-hide-xs">
        <!-- column -->
        <div class="fly-panel fly-column">
            <div class="layui-container">
                <ul class="layui-clear">
                    <li><a href="/Home/Index">首页</a></li>
                    @if (SortModel != null)
                    {
                        foreach (var item in SortModel)
                        {
                            <li><a href="/Novel/SelectNovelByType?type=@item.SortID">@item.SortName</a></li>
                        }
                    }
                </ul>
            </div>
        </div>	<!-- column end -->
    </div>
    <div class="layui-container">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8 content detail">
                <div class="fly-panel detail-box">
                    <h1>@Model.novelModel.NovelTitle</h1>
                    <div class="fly-detail-info">
                        <span class="layui-badge layui-bg-orange">精帖</span>
                        <div class="fly-admin-box">
                        </div>
                        <span class="fly-list-nums">
                            @if (Model.CommentItems != null)
                            {
                                <a href="javascript:;"><i class="iconfont" title="评论"></i>@Model.CommentItems.Count</a>
                            }
                            else
                            {
                                <a href="javascript:;"><i class="iconfont" title="评论"></i>0</a>
                            }<i class="iconfont" title="点击数"></i> @Model.novelModel.ClickNum
                        </span>
                    </div>
                    <div class="detail-about">

                        <div class="fly-detail-user"> <a href="/Novel/SelectNovelByUserId?UserID=@Model.novelModel.CreateUser" class="fly-link"> <cite>@Model.novelModel.CreateUserName</cite></a></div>
                        <div class="detail-hits" id="LAY_jieAdmin" data-id="20">
                            <span style="padding-right:20px;padding-left:10px; color: #FF7200">点赞数：@Model.novelModel.AgreeNum</span>
                            <span class="layui-btn layui-btn-xs jie-admin" id="like" type="exchange">点赞</span>

                        </div>
                        <div class="fly-detail-user" style="padding-top:10px">
                            <span style="padding-right: 20px;padding-left:10px;">反对数：@Model.novelModel.DisagreeNum</span>
                            <span class="layui-btn layui-btn-xs jie-admin" id="oppose" type="exchange">反对</span>
                        </div>
                    </div>
                    <div class="detail-body photos">
                        @Html.Raw(HttpUtility.HtmlDecode(Model.novelModel.NovelBody))
                    </div>
                </div>
                <!-- 回帖系列 -->
                <div class="fly-panel detail-box" id="flyReply">
                    <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                        <legend>回帖</legend>
                    </fieldset>
                    <ul class="jieda" id="jieda">
                        @if (Model.CommentItems != null)
                        {
                            foreach (var item in Model.CommentItems)
                            {
                                <li data-id="@item.CommentID" class="jieda-daan" style="margin-top:5px">
                                    <a name="item-1111111111"></a>
                                    <div class="detail-about detail-about-reply">
                                        <a class="fly-avatar" href="javascript:;">
                                            <img src="@item.CreateUserHeadPortrait" />
                                        </a>
                                        <div class="fly-detail-user">
                                            <a href="javascript:;" class="fly-link">
                                                <cite>@item.CreateUserName</cite>
                                            </a>
                                        </div>
                                        <div class="detail-hits">
                                            <span>@item.CreateTime</span>
                                        </div>
                                    </div>
                                    <div class="detail-body jieda-body photos">
                                        <p>@item.CommentBody</p>
                                    </div>
                                    <div class="jieda-reply">
                                        <a href="javascript:;" onclick='Commlike(@item.CommentID)'><span class="jieda-zan " type="zan"> <i class="iconfont icon-zan"></i> <em>@item.AgreeNum</em> </span></a>
                                        <a href="javascript:;" onclick='Reply(@item.CommentID)'>
                                            <span type="reply" id="Reply">
                                                <i class="iconfont icon-svgmoban53"></i>
                                                回复
                                            </span>
                                        </a>
                                    </div>
                                </li>
                                <div style="background-color:whitesmoke;padding:10px">
                                @if (item.Comments != null)
                                {
                                    foreach (var a in item.Comments)
                                    {
                                        <li data-id="@a.CommentID" class="jieda-daan"  style="margin-top:10px" >
                                            <a name="item-1111111111"></a>
                                            <div class="detail-about detail-about-reply">
                                                <a class="fly-avatar" href="javascript:;">
                                                    <img src="@a.CreateUserHeadPortrait" />
                                                </a>
                                                <div class="fly-detail-user">
                                                    <a href="javascript:;" class="fly-link">
                                                        <cite>@a.CreateUserName</cite>
                                                    </a>
                                                </div>
                                                <div class="detail-hits">
                                                    <span>@a.CreateTime</span>
                                                </div>
                                            </div>
                                            <div class="detail-body jieda-body photos">
                                                <p>@a.CommentBody</p>
                                            </div>
                                            <div class="jieda-reply">
                                                <a href="javascript:;" onclick='Commlike(@item.CommentID)'> <span class="jieda-zan " type="zan"> <i class="iconfont icon-zan"></i> <em>@item.AgreeNum</em> </span></a>
                                                @*<span type="reply">
                                                        <i class="iconfont icon-svgmoban53"></i>
                                                        回复
                                                    </span>*@
                                            </div>
                                        </li>
                                    }
                                }
                                </div>
                            }
                        }
                    </ul>
                    <div style="text-align: center">
                    </div>
                    <div class="layui-form layui-form-pane">
                        <form action="#" method="post">
                            <div class="layui-form-item layui-form-text">
                                <a name="comment"></a>
                                <div class="layui-input-block">
                                    <div class="layui-unselect fly-edit"><span type="yulan" title="预览"><i class="iconfont icon-yulan1"></i></span></div>
                                    @if (Model.novelModel.IsBan)
                                    {
                                        <textarea id="L_content" name="content" required="" readonly lay-verify="required" placeholder="你不能进行评论" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                                    }
                                    else
                                    {
                                        <textarea id="L_content" name="content" required="" lay-verify="required" placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                                    }
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <input type="hidden" name="id" value="20">
                                <input type="hidden" id="replyCommentId" name="replyCommentId" value="">
                                <button class="layui-btn" type="button" lay-filter="*" lay-submit>提交回复</button>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
            <div class="layui-col-md4">
                <dl class="fly-panel fly-list-one" id="HotTable"></dl>
                <div class="fly-panel">
                    <div class="fly-panel-title">
                        广告区域
                    </div>
                    <div class="fly-panel-main">
                        <a href="#" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">孤独的旅行家--旅行必备</a>
                    </div>
                </div>

                <div class="fly-panel fly-link">
                    <h3 class="fly-panel-title">友情链接</h3>
                    <dl class="fly-panel-main">
                        <dd><a href="http://www.12306.cn/mormhweb/" target="_blank">12306</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="http://www.ctrip.com/" target="_blank">携程</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="https://www.fliggy.com/" target="_blank">飞猪</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="https://www.qunar.com" target="_blank">去哪儿</a></dd>
                        <dd>
                        </dd>
                        <dd><a href="javascript:;" class="fly-link">申请友链qqming@126.com</a></dd>
                        <dd>
                        </dd>
                    </dl>
                </div>
            </div>
        </div>
    </div>
    <!-- 低部 -->
    <div class="fly-footer">
        <input type="hidden" id="NovelID" value="@Model.novelModel.NovelID">

    </div>
    <script src="~/Content/js/jquery.min.js"></script>
    <script src="~/Content/layui/layui.js"></script>
    <script>
        layui.use(['laypage', 'jquery', 'layer', 'form', 'element'], function () {
            var laypage = layui.laypage, $ = layui.jquery, layer = layui.layer, form = layui.form, element = layui.element;
            $.ajax({
                type: "post",
                url: "/Novel/GetNovelByHot",
                dataType: "json",
                success: function (res) {
                    if (res.code == 0) {
                        //渲染数据
                        var Content = "";
                        Content += "<dt class='fly-panel-title'>热门帖子</dt>"
                        $(res.data).each(function (n, Row) {
                            Content += `
                                                                                                            <dd>
                                                                                                                <a href="/Comment/Index?NovelID=${Row.NovelID}" class="fly-link">${Row.NovelTitle}</a><a href="/Comment/Index?NovelID=${Row.NovelID}">${Row.NovelSummary}</a>
                                                                                                                <span>${Row.AgreeNum}  点击量</span>
                                                                                                            </dd>`
                        })
                        $("#HotTable").html(Content);
                    }
                    else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                }
            });
            //文章点赞
            $("#like").click(function () {
                var params = {
                    NovelID: $("#NovelID").val()
                }
                $.ajax({
                    type: "post",
                    url: "/Novel/UpdateDisAgreeNum",
                    data: params,
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1
                            },
                                function () {
                                    setInterval(function () {
                                        window.location.href = '/Comment/Index?NovelID=' + $("#NovelID").val() + '';
                                    }, 2000);
                                });
                        }
                        else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                    }
                });
            });
            //文章反对
            $("#oppose").click(function () {
                var params = {
                    NovelID: $("#NovelID").val()
                }
                $.ajax({
                    type: "post",
                    url: "/Novel/SubDisAgreeNum",
                    data: params,
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1
                            },
                                function () {
                                    setInterval(function () {
                                        window.location.href = '/Comment/Index?NovelID=' + $("#NovelID").val() + '';
                                    }, 2000);
                                });
                        }
                        else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                    }
                });
            });
            //插入评论
            form.on('submit(*)', function (data) {
                var params = {
                    NovelID: $("#NovelID").val(),
                    CommentBody: $("#L_content").val()
                };

                $.ajax({
                    type: "post",
                    url: "/Comment/Insert",
                    data: params,
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1
                            },
                                function () {
                                    setInterval(function () {
                                        window.location.href = '/Comment/Index?NovelID=' + $("#NovelID").val() + '';
                                    }, 2000);
                                });
                        }
                        else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                    }
                });
            });

        });
        //评论点赞
        function Commlike(id) {
            var params = {
                CommentID: id
            }
            $.ajax({
                type: "post",
                url: "/Comment/CommAddAgreeNum",
                data: params,
                dataType: "json",
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {
                            icon: 1
                        },
                            function () {
                                setInterval(function () {
                                    window.location.href = '/Comment/Index?NovelID=' + $("#NovelID").val() + '';
                                }, 3000);
                            });
                    }
                    else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                }
            });
        }
        //评论回复
        function Reply(id) {
            //弹出回复子评论
            layer.open({
                title:'评论回复',
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                btn:'确定',
                yes: function (index, layero) {
                    var params = {
                        NovelID: $("#NovelID").val(),
                        GoalCommentID: id,
                        CommentBody: $("#replycontent").val()
                    }
                    $.ajax({
                        type: "post",
                        url: "/Comment/Insert",
                        data: params,
                        dataType: "json",
                        success: function (res) {
                            if (res.code == 0) {
                                layer.close(index);
                                layer.msg(res.msg, {
                                    icon: 1
                                },
                                    function () {
                                        setInterval(function () {
                                            window.location.href = '/Comment/Index?NovelID=' + $("#NovelID").val() + '';
                                        }, 3000);
                                    });
                            }
                            else {
                                layer.close(index);
                                layer.msg(res.msg, { icon: 2 });
                            }
                        }
                    });
                },
                content: '<div style="margin:5px"><textarea id="replycontent" class="layui-textarea"></textarea></div>'
            });
        }
    </script>

    <ul class="layui-fixbar"><li class="layui-icon" lay-type="bar1" style="background-color:#009688"></li><li class="layui-icon layui-fixbar-top" lay-type="top" style="background-color: rgb(0, 150, 136); display: none;"></li></ul><div class="layui-layer-move" style="cursor: move; display: none;"></div>
</body>
</html>
